package com.aegean.MonitorExamSYS.center.action;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.aegean.MonitorExamSYS.center.business.CenterBusiness;
import com.opensymphony.xwork2.ActionSupport;

@Controller("ConfirmArrangeForMonitor")
@Scope("prototype")
public class ConfirmArrangeForMonitor extends ActionSupport implements
		ServletRequestAware {
	@Resource
	CenterBusiness business;
	private HttpServletRequest request;
	private HttpSession session;
	private String msg;
	private boolean success;
	private Map<Integer, List<Integer>> monitorSelectedMap;// 定义每个考场的监考人员信息
	private int exam_Id;// 考试Id
    private Date startTime;
	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public Map<Integer, List<Integer>> getMonitorSelectedMap() {
		return monitorSelectedMap;
	}

	public void setMonitorSelectedMap(
			Map<Integer, List<Integer>> monitorSelectedMap) {
		this.monitorSelectedMap = monitorSelectedMap;
	}

	public int getExam_Id() {
		return exam_Id;
	}

	public void setExam_Id(int exam_Id) {
		this.exam_Id = exam_Id;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		monitorSelectedMap = (Map<Integer, List<Integer>>) session
				.getAttribute("MonitorSelectedMap");
		success = business.confirmArrangeMonitors(exam_Id,startTime, monitorSelectedMap);
		if (success == true) {
            msg="恭喜，已经成功完成该考试相关的所有考点以及考场的监考人员设置！";
		} else {
			msg="对不起，对于该考试相关考点以及考场的监考人员设置出错！";
		}
		return SUCCESS;
	}

	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		this.request = arg0;
		this.session = this.request.getSession();

	}
}
